package kin.system.util;

import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;

public class DeepQuery {

	public static Object query(Object root, Map condition, Class target) {

		Class c = root.getClass();

		Field[] fs = c.getDeclaredFields();

		for (Field f : fs) {
			Class t = f.getType();

			if (!ClassUtil.isBaseDataType(t)) {
				// System.out.println(f.getName() + ":"+
				// DeepQuery.isBaseDataType(t));

				Object obj =ClassUtil.getValue(root, f.getName());
				if (obj != null) {
					if (obj.getClass().getName().equals(target.getName()))
						System.out.println(obj.getClass().getName());
				}

			} else {
				System.out.println("ppp");
				if (t.isAssignableFrom(Set.class)) {
					Type fc = f.getGenericType();

					if (fc instanceof ParameterizedType) {
						ParameterizedType pt = (ParameterizedType) fc;

						Class genericClazz = (Class)pt.getActualTypeArguments()[0];

						System.out.println("genericClazz:"+ genericClazz.getName());

					}
				}
			}
		}
		return null;

	}

	

	
}
